<template>
  <el-container class="layout-container">
    <!-- 左侧菜单 -->
    <el-aside width="200px">
      <div class="el-aside__logo"></div>
      <el-menu
        active-text-color="#ffd04b"
        background-color="#232323"
        text-color="#fff"
        router
      >//
        <el-menu-item index="/system/teacher">
          <el-icon><Avatar /></el-icon>
          <span>教师管理</span>
        </el-menu-item>
        <el-menu-item index="/system/student">
          <el-icon><UserFilled /></el-icon>
          <span>学生管理</span>
        </el-menu-item>
        <el-menu-item index="/system/admin">
          <el-icon><User /></el-icon>
          <span>管理员信息</span>
        </el-menu-item>
        <el-menu-item index="/system/classroom">
          <el-icon><HomeFilled /></el-icon>
          <span>教室管理</span>
        </el-menu-item>
        <el-menu-item index="/system/course">
          <el-icon><Histogram /></el-icon>
          <span>课程管理</span>
        </el-menu-item>

        <el-menu-item index="/system/major">
          <el-icon><Histogram /></el-icon>
          <span>专业管理</span>
        </el-menu-item>

        <el-menu-item index="/system/manage">
          <el-icon><Histogram /></el-icon>
          <span>排课管理</span>
        </el-menu-item>

        <el-menu-item index="/system/score">
          <el-icon><Histogram /></el-icon>
          <span>学生成绩信息管理</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    <!-- 右侧主区域 -->
    <el-container>
      <!-- 头部区域 -->
      <el-header>
        <div>小组<strong>OMG+GALAEE</strong></div>
        <el-dropdown placement="bottom-end" @command="handleCommand">
          <span class="el-dropdown__box">
            <el-avatar :src="avatar" />
            <el-icon>
              <CaretBottom />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="logout" :icon="SwitchButton"
                >退出登录</el-dropdown-item
              >
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </el-header>
      <!-- 中间区域 -->
      <el-main>
        <router-view></router-view>
      </el-main>
      <!-- 底部区域 -->
      <el-footer>高校教务系统</el-footer>
    </el-container>
  </el-container>
</template>

<script setup>
import { SwitchButton, CaretBottom } from "@element-plus/icons-vue";
import avatar from "@/assets/default.png";
import { ElMessage, ElMessageBox } from "element-plus";
import { useRouter } from "vue-router";
const router = useRouter();

const handleCommand = (command) => {
  //判断指令
  console.log(9999);
  if (command === "logout") {
    //退出登录
    ElMessageBox.confirm("您确认要退出吗?", "温馨提示", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
    })
      .then(async () => {
        //2.跳转到登录页面
        router.push("/");
        ElMessage({
          type: "success",
          message: "退出登录成功",
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: "用户取消了退出登录",
        });
      });
  }
};
</script>

<style lang="scss" scoped>
.layout-container {
  height: 100vh;

  .el-aside {
    background-color: #232323;

    &__logo {
      height: 120px;
      background: url("@/assets/touxiang.jpg") no-repeat center / 120px auto;
    }

    .el-menu {
      border-right: none;
    }
  }

  .el-header {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .el-dropdown__box {
      display: flex;
      align-items: center;

      .el-icon {
        color: #999;
        margin-left: 10px;
      }

      &:active,
      &:focus {
        outline: none;
      }
    }
  }

  .el-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
  }
}
</style>
